package com.wechat.servlet.Relation;

import com.wechat.DAO.DaoImpl.UserRelationDAOIpml;
import com.wechat.DAO.UserRelationDAO;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DeleteRelationServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String UID = request.getParameter("UID");
        String FID = request.getParameter("FID");
        UserRelationDAO userRelationDAO = new UserRelationDAOIpml();
        try {
            if(userRelationDAO.deleteRelation(UID,FID)){
                response.getWriter().write("success");
            }else {
                response.getWriter().write("fail");
            }
        }catch (Exception e){
            e.printStackTrace();
            response.getWriter().write("fail");
            return;
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
